import { defineStore } from "pinia";
import { user } from "@/api/index";

const useUserStore = defineStore("UserStore", {
  state: () => {
    return {
      user_info: {
        name: "",
        headimgurl: "",
        identity: "", // 0管理员，1普通用户，2会员
        enddate: "",
      },
    };
  },
  actions: {
    async get_user_info() {
      const {
        data: { name = "", headimgurl = "", identity= "", enddate= "" },
      } = await user();
      this.user_info.enddate = enddate;
      this.user_info.identity = identity;
      this.user_info.name = name;
      this.user_info.headimgurl = headimgurl;
    },
  },
});

export default useUserStore;
